Skip to content

WIP: In-game push blocks#2049

Draft
wjt wants to merge 5 commits intomainfrom
wjt/in-game-push-blocks-prototype
Draft

WIP: In-game push blocks#2049
wjt wants to merge 5 commits intomainfrom
wjt/in-game-push-blocks-prototype

Conversation

@wjt
Copy link
Member

@wjt wjt commented Mar 12, 2026

No description provided.

@github-actions
Copy link

Play this branch at https://play.threadbare.game/branches/endlessm/wjt/in-game-push-blocks-prototype.

(This launches the game from the start, not directly at the change(s) in this pull request.)

@manuq
Copy link
Collaborator

manuq commented Mar 12, 2026

Play this branch at https://play.threadbare.game/branches/endlessm/wjt/in-game-push-blocks-prototype.

(This launches the game from the start, not directly at the change(s) in this pull request.)

Actually it's playable in: https://play.threadbare.game/branches/endlessm/wjt/in-game-push-blocks-prototype/#res://in_game_sokoban_test.tscn

@manuq
Copy link
Collaborator

manuq commented Mar 12, 2026

@wjt @JoniCeceri I see two options here:

  1. The boxes could be pushed without any grid constraint (like in this prototype or in MINIT).
  2. Or, the boxes could be pushed in a grid (with an AnimatableBody2D node maybe?) while the player move towards the box or use the "repel" action on them.

I think both have potential, it all depends on the kind of puzzles we want. Maybe 2 can open up more possibilities for pattern-based puzzles? Check this level for StoryQuest "Gazzart" that does the latter: https://game-lab-5-0-utp-group-6-team-3.github.io/threadbare/#quests/story_quests/gazzart/2_game_castle/gazzart_castle

@med-bc and team, if you can help us understand how you did the boxes puzzles, that would be great!

@wjt wjt force-pushed the wjt/in-game-push-blocks-prototype branch from 3796214 to 5f6ba40 Compare March 13, 2026 11:25
@manuq
Copy link
Collaborator

manuq commented Mar 13, 2026

@wjt you made it work! Nice!

image

Comment on lines +52 to +55
# This doesn't work because at the point when the 1×1px area in the centre of a block
# travelling rightwards touches a block of water at (x, y),
# its centre is still in tile (x - 1, y).
# var coords := tile_map.local_to_map(tile_map.to_local(global_position))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why the previous version didn't work. Actually what I originally implemented was the section just above that uses get_coords_for_body_rid but then I thought, well, how hard can it be to use local_to_map? and didn't even test it before pushing.

@wjt
Copy link
Member Author

wjt commented Mar 13, 2026

I have tried several different ways to move the blocks in response to the repel action:

  • Keep the blocks as a CharacterBody2D, set velocity in the closest cardinal direction of the repel; decelerate at a constant rate, with the two constants chosen (with some dodgy maths) to move the block almost exactly 64px in that direction.
  • Make the blocks be a RigidBody2D. What I couldn't make work here is that we want the player pushing against the body to never move it (as if it's a wall); but I couldn't make that work.

@wjt
Copy link
Member Author

wjt commented Mar 13, 2026

The other problem with the "repel" action is that these puzzles rely on exact control of the blocks, but the repel circle is wide enough that it's hard to avoid repelling two blocks at once if they are close together. I don't think it's going to work.

untitled.mp4

The third thing to try is hitting it with the sword, which would be most easily prototyped by making it hookable I guess but with negative weight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants